<?php
/**
 *    @version [ Masterton ]
 *    @package hwdVideoShare
 *    @copyright (C) 2007 - 2009 Highwood Design
 *    @license Creative Commons Attribution-Non-Commercial-No Derivative Works 3.0 Unported Licence
 *    @license http://creativecommons.org/licenses/by-nc-nd/3.0/
 */
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

global $print_ulink, $print_glink, $mainframe, $smartyvs, $option, $Itemid, $hwdvsTemplateOverride;
$c = hwd_vs_Config::get_instance();

if (!file_exists(JPATH_SITE.DS.'components'.DS.'com_community')) {
	echo "<div style=\"border:1px solid #c30;color:#c30;margin: 0 0 5px 0;padding: 5px;font-weight: bold;text-align:left;text-align:center;\">You are trying to use the JomSocial template in hwdVideoShare but you don't have JomSocial installed. Please use another template.</div>";
}

$plugin =& JPluginHelper::getPlugin('hwdvs-template', 'jomsocial');
$pluginParams = new JParameter( $plugin->params );
$hwdvsTemplateOverride['js_template'] = $pluginParams->def( 'js_template', 'default' );
$hwdvsTemplateOverride['thumbWidth1'] = $pluginParams->def( 'thumbWidth1', '120' );
$hwdvsTemplateOverride['thumbWidth2'] = $pluginParams->def( 'thumbWidth2', '80' );
$hwdvsTemplateOverride['thumbWidth3'] = $pluginParams->def( 'thumbWidth3', '80' );
$hwdvsTemplateOverride['thumbWidth4'] = $pluginParams->def( 'thumbWidth4', '80' );
$hwdvsTemplateOverride['thumbWidth5'] = $pluginParams->def( 'thumbWidth5', '120' );
$hwdvsTemplateOverride['thumbWidth6'] = $pluginParams->def( 'thumbWidth6', '120' );
$hwdvsTemplateOverride['thumbWidth7'] = $pluginParams->def( 'thumbWidth7', '80' );
$hwdvsTemplateOverride['thumbWidth8'] = $pluginParams->def( 'thumbWidth8', '80' );
$hwdvsTemplateOverride['thumbWidth9'] = $pluginParams->def( 'thumbWidth9', '80' );
$hwdvsTemplateOverride['beingWatchNow'] = $pluginParams->def( 'beingWatchNow', '3' );
$hwdvsTemplateOverride['vpr'] = $pluginParams->def( 'vpr', '3' );
$hwdvsTemplateOverride['cpr'] = $pluginParams->def( 'cpr', '4' );
$hwdvsTemplateOverride['gpr'] = $pluginParams->def( 'gpr', '2' );
$hwdvsTemplateOverride['hideSubcats'] = $pluginParams->def( 'hideSubcats', '0' );
$hwdvsTemplateOverride['homeButton'] = intval($pluginParams->def( 'homeButton', '0' ));
$hwdvsTemplateOverride['jsItemid'] = intval($pluginParams->def( 'jsItemid', $Itemid ));
$hwdvsTemplateOverride['playerAlign'] = $pluginParams->def( 'playerAlign', 'L' );
$hwdvsTemplateOverride['loadCarousel'] = 0;

$template_folder = $mainframe->getUserState( "com_hwdvideoshare.template_folder", '' );
$template_element = $mainframe->getUserState( "com_hwdvideoshare.template_element", '' );
if (!empty($template_folder) && !empty($template_element)) {

	$c->hwdvids_template_path = $template_folder;
	$c->hwdvids_template_file = $template_element;

}
$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.JURI::root( true ).'/plugins/hwdvs-template/'.$c->hwdvids_template_file.'/template.css" type="text/css" />');
$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.JURI::root( true ).'/plugins/hwdvs-template/'.$c->hwdvids_template_file.'/css/rating.css" type="text/css" />');

if ($option !== "com_community")
{
	$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.JURI::root( true ).'/components/com_community/assets/window.css" type="text/css" />');
	$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.JURI::root( true ).'/components/com_community/assets/autocomplete.css" type="text/css" />');
	$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.JURI::root( true ).'/components/com_community/assets/jquery-1.3.2.pack.js"></script>');
	$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.JURI::root( true ).'/components/com_community/assets/script-1.2.js"></script>');

	if ($hwdvsTemplateOverride['js_template'] == "default" || $hwdvsTemplateOverride['js_template'] == "blueface" || $hwdvsTemplateOverride['js_template'] == "bubble" || $hwdvsTemplateOverride['js_template'] == "blackout")
	{
		$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.JURI::root( true ).'/components/com_community/templates/'.$hwdvsTemplateOverride['js_template'].'/css/style.css" type="text/css" />');
	}
	else if ($hwdvsTemplateOverride['js_template'] == "rt_affinity_j15")
	{
		if (file_exists(JPATH_SITE.DS.'templates'.DS.'rt_affinity_j15'.DS.'html'.DS.'com_community'.DS.'css'.DS.'style.css'))
		{
			$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.JURI::root( true ).'/templates/rt_affinity_j15/html/com_community/css/style.css" type="text/css" />');
		}
		else
		{
			$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.JURI::root( true ).'/components/com_community/templates/default/css/style.css" type="text/css" />');
		}
	}
}


$template_folder = $mainframe->getUserState( "com_hwdvideoshare.template_folder", '' );
$template_element = $mainframe->getUserState( "com_hwdvideoshare.template_element", '' );

if (!empty($template_folder) && !empty($template_element)) {

	$c->hwdvids_template_path = $template_folder;
	$c->hwdvids_template_file = $template_element;

}

if ($fe && file_exists(JPATH_PLUGINS.DS.'hwdvs-template'.DS.'jomsocial'.DS.'templates'.DS.$hwdvsTemplateOverride['js_template'].DS.'index.tpl'))
{
	$smartyvs->template_dir = JPATH_PLUGINS.DS.$c->hwdvids_template_path.DS.$c->hwdvids_template_file.DS.'templates'.DS.$hwdvsTemplateOverride['js_template'];
}

if ($hwdvsTemplateOverride['homeButton'] !== 2) {
	$smartyvs->assign("print_HomeButton", 1);
	if ($hwdvsTemplateOverride['homeButton'] == 0) {
		$jsItemid = $hwdvsTemplateOverride['jsItemid'];
		$smartyvs->assign("HomeButtonLink", JRoute::_("index.php?option=com_community&view=frontpage&Itemid=$jsItemid") );
	} else {
		$smartyvs->assign("HomeButtonLink", JRoute::_('index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=frontpage') );
	}

}

$smartyvs->assign("bwn_no", $hwdvsTemplateOverride['beingWatchNow']);
$smartyvs->assign("vpr", $hwdvsTemplateOverride['vpr']);
$smartyvs->assign("gpr", $hwdvsTemplateOverride['gpr']);
$smartyvs->assign("cpr", $hwdvsTemplateOverride['cpr']);

if ($hwdvsTemplateOverride['hideSubcats'] == "1") {
	$smartyvs->assign("hideSubcats", 1);
} else {
	$smartyvs->assign("hideSubcats", 0);
}

if ($hwdvsTemplateOverride['playerAlign'] == "C") {
	$smartyvs->assign("playerAlign", "C");
} else  {
	$smartyvs->assign("playerAlign", "L");
}

$vsvboxwidth = intval(100/$hwdvsTemplateOverride['vpr'])-2;
$vsgboxwidth = intval(100/$hwdvsTemplateOverride['gpr'])-2;
$vscboxwidth = intval(100/$hwdvsTemplateOverride['cpr'])-2;

$var = "<style type=\"text/css\">

		#community-wrap .videoBox {
			width: ".$vsvboxwidth ."%;
			float:left;
		}

		#community-wrap .groupBox {
			width: ".$vsgboxwidth ."%;
			float:left;
		}

		#community-wrap .categoryBox {
			width: ".$vscboxwidth ."%;
			float:left;
		}


		#community-wrap .box
		{
			background: transparent url('".JURI::root( true )."/images/blank.png') no-repeat top center!important;
		}

</style>";
$mainframe->addCustomHeadTag($var);
return;

function templateSetCategoryTab($tab='videos')
{
}

?>